package model.hospital;

import util.StringMapper;

import java.util.HashMap;

public class Location {
    private int buildingNumber = 0;
    private int floorNumber = 0;
    private int roomNumber = 0;

    public Integer getBuildingNumber() {
        return buildingNumber;
    }

    public void setBuildingNumber(int buildingNumber) {
        this.buildingNumber = buildingNumber;
    }

    public Integer getFloorNumber() {
        return floorNumber;
    }

    public void setFloorNumber(int floorNumber) {
        this.floorNumber = floorNumber;
    }

    public Integer getRoomNumber() {
        return roomNumber;
    }

    public void setRoomNumber(int roomNumber) {
        this.roomNumber = roomNumber;
    }

    public Location() {
    }

    public Location(int buildingNumber, int floorNumber, int roomNumber) {
        this.buildingNumber = buildingNumber;
        this.floorNumber = floorNumber;
        this.roomNumber = roomNumber;
    }

    @Override
    public String toString() {
        return "Location{" +
                "buildingNumber=" + buildingNumber +
                ", floorNumber=" + floorNumber +
                ", roomNumber=" + roomNumber +
                '}';
    }

    public static void main(String[] args) {

        HashMap<String,String> map = StringMapper.toMap("buildingNumber:123");

        Location location = new Location(
                map.containsKey("buildingNumber")?
                        Integer.parseInt(map.get("buildingNumber")):0,
                map.containsKey("floorNumber")?
                        Integer.parseInt(map.get("floorNumber")):0,
                map.containsKey("roomNumber")?
                        Integer.parseInt(map.get("roomNumber")):0
        );

        System.out.println(location);
    }
}
